import httpInstance from "@/utils/http";

//获取所有的社团+按id搜索社团
export function getClubListAllAPI(
  current: number,
  pageSize: number,
  query: string
) {
  return httpInstance({
    url: "/club/list/all",
    method: "POST",
    data: {
      current,
      pageSize,
      query,
    },
  });
}

//获取所有的社团类型
export function getClubTypeCountAPI() {
  return httpInstance({
    url: "/club/type",
    method: "GET",
  });
}


//根据社团id获取详细的社团信息
export function getClubVoByIdAPI(clubId: number) {
  return httpInstance({
    url: "/club/get/vo",
    method: "GET",
    params: {
      clubId,
    },
  });
}

//获取社团成员列表


//修改社团信息
export function updateClubAPI(
  id: number,
  clubName: string,
  userId: number,
  tags: string[],
  introduction: string
) {
  return httpInstance({
    url: "/club/update",
    method: "POST",
    data: {
      id,
      clubName,
      userId,
      introduction,
      tags,
    },
  });
}
//添加社团
export function addClubAPI(
  clubName: string,
  userId: number,
  introduction: string
) {
  return httpInstance({
    url: "/club/add",
    method: "POST",
    data: {
      clubName,
      userId,
      introduction,
    },
  });
}

//获取社团申请列表+查询
export function getClubApplicationListAPI(
  current: number,
  pageSize: number,
  query: number
) {
  return httpInstance({
    url: "club-application/list/page",
    method: "POST",
    data: {
      current,
      pageSize,
      query, // 查询条件
    },
  });
}
//删除申请社团信息
export function deleteClubApplicationAPI(ids: number[]) {
  return httpInstance({
    url: "club-application/delete",
    method: "DELETE",
    params: {
      ids,
    },
  });
}


// 根据社团id获取社团成员（使用POST，body为JSON，参数名为clubId）
export function listClubMembersAPI(clubId: number) {
  return httpInstance({
    url: "/club/list/user",
    method: "POST",
    data: {
      clubId
    },
  });
}

//单个删除社团
export function deleteClubAPI(id: number) {
  return httpInstance({
    url: "/club/delete",
    method: "POST",
    data: {
      id
    },
  });
}
//批量删除社团信息
export function batchDeleteClubsAPI(
  deleteList: Array<{
    clubId: number;
    userId: number;
  }>
) {
  return httpInstance({
    url: "/club/delete",
    method: "DELETE",
    data: deleteList,
  });
}

//删除社团请求
export function deleteClubApplicationsAPI(ids: number[]) {
  return httpInstance.delete("/club-application/delete", {
    params: { ids },
    paramsSerializer: {
      indexes: null,
    },
  });
}


// 添加社团成员
export function addClubMemberAPI(params: { userId: number; clubId: number; identity: string }) {
  return httpInstance({
    url: "/club/member/add",
    method: "POST",
    data: params,
  });
}

// 移除社团成员
export function deleteClubMemberAPI(params: { userId: number; clubId: number }) {
  return httpInstance({
    url: "/club/member/delete",
    method: "POST",
    data: params,
  });
}
